{% import '@SyliusAdmin/shared/helper/table.html.twig' as table %}
{% import '@SyliusAdmin/shared/helper/pagination.html.twig' as pagination %}

{% set resources = hookable_metadata.context.resources %}
{% set data = resources.data %}
{% set definition = resources.definition %}

{% if data|length > 0 %}
    <div class="card">
        <div class="card-body border-bottom py-3">
            <div class="d-flex">
                {% if data|length > 0 and definition.actionGroups.bulk is defined and definition.getEnabledActions('bulk')|length > 0 %}
                    <div class="sylius-grid-nav__bulk grid">
                        {% for action in definition.getEnabledActions('bulk') %}
                            {{ sylius_grid_render_bulk_action(resources, action, null) }}
                        {% endfor %}
                    </div>
                {% endif %}
                <div class="ms-auto">
                    {{ pagination.number_of_results_selector(data, definition.limits) }}
                </div>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table card-table table-vcenter datatable" {{ sylius_test_html_attribute('grid-table') }}>
                <thead>
                <tr>
                    {{ table.headers(resources, resources.definition, app.request.attributes) }}
                </tr>
                </thead>
                <tbody {{ sylius_test_html_attribute('grid-table-body') }}>
                {% for row in resources.data %}
                    {{ table.row(resources, resources.definition, row) }}
                {% endfor %}
                </tbody>
            </table>
        </div>
        <div class="card-footer d-flex align-items-center gap-2 flex-wrap">
            <div class="text-muted">
                {{ pagination.results_count(data) }}
            </div>
            <div class="ms-auto">
                {{ pagination.simple(data) }}
            </div>
        </div>
    </div>
{% endif %}
